package controllers.validation;

import org.junit.Assert;
import org.junit.Test;

import ch.bfh.abcm.rems.gateway.GateWayMessageType;
import ch.bfh.abcm.rems.gateway.GatewayMessage;

public class EffectiveValueAndSystemOkay extends AbstractValidationTest {

    @Test
    public void testEffectiveValueAndSystemOkayTemperature() throws InterruptedException {
        insertCorrectTempLuxHumSensorData(5);
        insertCorrectNodeAverages(5);
        new ValidationJob(HOST_IP_TEMPERATURE).now();
        Thread.sleep(WAIT_FOR_RECEIVING);
        GatewayMessage message = receiverimplemntation.getGatewayMessage();
        Assert.assertNull(receiverimplemntation.getUpdateNodeConfigMessage());
        Assert.assertNull(receiverimplemntation.getUpdateUserConfigMessage());
        Assert.assertEquals(GateWayMessageType.SYSTEM_OK, message.getMessageType());
        Assert.assertEquals("ok", message.getMessage());
    }
    
    @Test
    public void testEffectiveValueAndSystemOkayAmbient() throws InterruptedException {
        insertCorrectTempLuxHumSensorData(5);
        insertCorrectNodeAverages(5);
        new ValidationJob(HOST_IP_AMBIENT).now();
        Thread.sleep(WAIT_FOR_RECEIVING);
        GatewayMessage message = receiverimplemntation.getGatewayMessage();
        Assert.assertNull(receiverimplemntation.getUpdateNodeConfigMessage());
        Assert.assertNull(receiverimplemntation.getUpdateUserConfigMessage());
        Assert.assertEquals(GateWayMessageType.SYSTEM_OK, message.getMessageType());
        Assert.assertEquals("ok", message.getMessage());
    }
    
    @Test
    public void testEffectiveValueAndSystemOkayHumidity() throws InterruptedException {
        insertCorrectTempLuxHumSensorData(5);
        insertCorrectNodeAverages(5);
        new ValidationJob(HOST_IP_HUMIDITY).now();
        Thread.sleep(WAIT_FOR_RECEIVING);
        GatewayMessage message = receiverimplemntation.getGatewayMessage();
        Assert.assertNull(receiverimplemntation.getUpdateNodeConfigMessage());
        Assert.assertNull(receiverimplemntation.getUpdateUserConfigMessage());
        Assert.assertEquals(GateWayMessageType.SYSTEM_OK, message.getMessageType());
        Assert.assertEquals("ok", message.getMessage());
    }
}